<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>数据采集</title>
	<script type="text/javascript">
	
		function checkTask() {
			var name = $("#name").val();
			var nameMsg = $("#nameMsg");
			var alias = $("#alias").val();
			var aliasMsg = $("#aliasMsg");
			
			var nameRs = true;
			var aliasRs = true;
			if($.trim(name) == "") {
				nameMsg.css("color", "red").html("任务名称必须填写！");
				nameRs = false;
			} else {
				nameMsg.html("");
			}
			
			var reg = new RegExp("^[a-zA-Z_][a-zA-Z_0-9]*$");
			if(reg.test($.trim(alias))) {
			    var updateTaskId = $("#updateTaskId").val();
			    
			    if(updateTaskId == "") {
				    $.ajax({
				          async: false,
				    	  type: "POST",
						  url: "ajaxCheckTaskAliasExist.do",
						  data: {'collectionTask.taskAlias':$.trim(alias)},
						  dataType:'json',
						  success: function(msg){
						     if(!msg) {
						     	aliasMsg.html("");
						     } else {
						     	aliasRs = false;
						     	aliasMsg.css("color", "red").html("任务英文别名已经存在！");
						     }
						  }
				    });
			    } else {
			    	aliasMsg.html("");
			    }
			} else {
				aliasMsg.css("color", "red").html("任务英文别名必须填写且为有效字符！");
				aliasRs = false;
			}
			return nameRs && aliasRs;
		}
	</script>
</head>
  <body>
       <div class="content_bg">
 	 	<div class="rhead">
 	 		<div class="rpos">当前位置:  数据采集 - 新建任务</div>
 	 	</div>
 	 	
 	 	<s:form action="createCollectionTask" theme="simple" onsubmit="return checkTask()" method="post">
 	 		<s:hidden name="collectionTask.id" id="updateTaskId"/>
 	 		<s:hidden name="taskId"/>
	 	 	<div class="rhead">
	 	 		<div class="textRow"><div class="textLabel">任务名称(<span style="color:red">*</span>)：</div>
	 	 		<div class="textContent"><s:textfield name="collectionTask.taskName" cssClass="textInfo" size="40" maxlength="100" id="name"/> <span id="nameMsg" style="color:red"></span></div>
	 	 		</div>
	 	 		<div class="textRow"><div class="textLabel">任务英文别名(<span style="color:red">*</span>)：</div>
	 	 		<div class="textContent"><s:textfield name="collectionTask.taskAlias" cssClass="textInfo" size="40" maxlength="100" id="alias"/> <span id="aliasMsg" style="color:red"></span></div>
	 	 		</div>
	 	 	</div>
	 	 	<div class="rhead">
	 	 		<span style="margin-left:140px"><s:submit value="下一步"></s:submit></span>
	 	 	</div>
 	 	</s:form>
 	   </div>
  </body>
</html>



